package com.ibm.wsbp.worklight.security;

import java.util.Map;

import com.worklight.auth.api.UserIdentity;
import com.worklight.auth.ext.UserNamePasswordLoginModule;

public class UsrPwdLoginModule extends UserNamePasswordLoginModule {
	private String userName;
	private String password;
	private String userDisplayName;

	@Override
	public void abort() {
		userName = null;
		password = null;
		userDisplayName = null;

	}

	@Override
	public UserIdentity createIdenity(String realm) {
		// TODO Auto-generated method stub
		return createUserIdentity(realm, userName, password, userDisplayName,
				null, null);
	}

	@Override
	public boolean login(Map<String, Object> authenticationData) {
		userName = getUserName(authenticationData);
		password = getPassword(authenticationData);
		if ("worklight".equals(userName) && "worklight".equals(password))
			return true;
		else
			return false;
	}

	@Override
	public void logout() {
		userName = null;
		password = null;
		userDisplayName = null;
	}

}
